//
//  QXSocketManager.h
//  Pods
//
//  Created by Qianxia on 2017/1/5.
//
//

#import <Foundation/Foundation.h>
#import <SocketRocket/SocketRocket.h>


/// 需要重新登录通知
FOUNDATION_EXPORT NSString * const ReloginNotificationKey;

typedef NS_ENUM(NSUInteger, QXSocketConnectionStatus){
    QXSocketConnectionStatusRunning,
    QXSocketConnectionStatusConnecting,
    QXSocketConnectionStatusClosing,
    QXSocketConnectionStatusClosed,
    QXSocketConnectionStatusFetching,
    QXSocketConnectionStatusFetched
};

@interface QXSocketManager : NSObject<SRWebSocketDelegate>


/**
 连接状态
 */
@property (assign, nonatomic) QXSocketConnectionStatus status;

/**
 设置连接url

 @param url 连接url
 */
+ (void)setUrl:(nonnull NSString *)url;

/**
 Returns the singleton instance of this class.
 */
+ (nonnull instancetype)manager;

/**
 登录
 
 @param userId 用户uuId
 @param token 登录token
 @param isDriver 是否是司机端
 */
- (void)loginWithUserId:(nullable NSString *)userId token:(nullable NSString *)token isDriver:(BOOL)isDriver;

/**
 重新连接
 */
- (void)reconnect;
- (void)close;

/**
 发送数据
 
 @param data 字典
 */
- (void)send:(NSDictionary *)data;

/**
 注册长连接类型

 @param type 长连接类型
 @param notificationName 通知名称
 */
- (void)registerType:(nonnull NSString *)type notificationName:(nonnull NSString *)notificationName;


/**
 移除注册的通知

 @param type 长连接类型
 @param notificationName 通知名称
 */
- (void)removeNotificationType:(NSString *)type notificationName:(NSString *)notificationName;
@end
